package neusoft.edu.cn.guanshangshiguang.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import neusoft.edu.cn.guanshangshiguang.Listener.OnItemClickListener;
import neusoft.edu.cn.guanshangshiguang.R;
import neusoft.edu.cn.guanshangshiguang.bean.CommentOnlineBean;
import neusoft.edu.cn.guanshangshiguang.bean.OnlineBookListBean;
import neusoft.edu.cn.guanshangshiguang.common.Common;
import neusoft.edu.cn.guanshangshiguang.item.BookDetailsItemViewHolder;
import neusoft.edu.cn.guanshangshiguang.item.ContentItemViewHolder;

public class CommentOnlineAdapter extends RecyclerView.Adapter<ContentItemViewHolder> {
    private List<CommentOnlineBean> onlineBookListBeanList;
    private OnItemClickListener myOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener listener){
        myOnItemClickListener=listener;
    }

    public void setDate(List<CommentOnlineBean> dateItemList){
        this.onlineBookListBeanList =dateItemList;
        notifyDataSetChanged();//通知数据集发生变化
    }

    @NonNull
    @Override
    public ContentItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        LayoutInflater layoutInflater = LayoutInflater.from(viewGroup.getContext());
        View itemView = layoutInflater.inflate(R.layout.itemcontent_layout,viewGroup,false);
        ContentItemViewHolder viewHolder = new ContentItemViewHolder(itemView);
        return viewHolder;

    }

    @Override
    public void onBindViewHolder(@NonNull ContentItemViewHolder bookDetailsItemViewHolder, final int i) {
        final CommentOnlineBean dataBean = onlineBookListBeanList.get(i);

        bookDetailsItemViewHolder.content_name.setText(dataBean.getUid());
        bookDetailsItemViewHolder.content_time.setText(dataBean.getComment_time());
        bookDetailsItemViewHolder.content.setText(dataBean.getComment());

    }

    @Override
    public int getItemCount() {
        if(onlineBookListBeanList !=null)
            return onlineBookListBeanList.size();
        else
            return 0;
//        return shopDateList.size();//返回列表显示的数据个数
    }
}
